import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Stack;

/**
 * 力扣232:用栈实现队列
 */

class MyQueue {
    Stack<Integer> stack1;
    Stack<Integer> stack2;
    /** 初始化 */
    public MyQueue() {
        stack1=new Stack<>();
        stack2=new Stack<>();
    }

    /** 压入. */
    public void push(int x) {
        stack1.push(x);
    }

    /** 弹出 */
    public int pop() {
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }

    /** 查看. */
    public int peek() {
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.peek();
    }

    /** 判空 */
    public boolean empty() {
        return stack2.isEmpty()&&stack1.isEmpty();
    }
}